package xin.yogee.ms.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 文件上传配置
 *
 * @author JackieQ
 * @since 2019/4/10
 */

@Configuration
public class UploadFileConfig extends WebMvcConfigurerAdapter {

    @Value("${file-path}")
    private String savePath;

    @Value("${file-accessPath}")
    private String staticAccessPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticAccessPath).addResourceLocations("file:" + savePath);
        super.addResourceHandlers(registry);
    }
}
